<template>
  <el-table
      :data="tableData.filter(data => !search || data.name.toLowerCase().includes(search.toLowerCase()))"
      stripe
      style="width: 100%">

    <el-table-column
        label="上传日期"
        prop="ddate">
    </el-table-column>
    <el-table-column
        label="文件名"
        width="280">
      <template slot-scope="scope">
        <el-popover trigger="hover" placement="top">
          <p>文件名: {{ scope.row.dname }}</p>
          <p>文件大小: {{ scope.row.dsize }}(B)</p>
          <div slot="reference" class="name-wrapper">
            <el-button size="medium" style="border: none" @click="dirshow(scope.row.dname)">  <i class="el-icon-picture-outline">{{scope.row.dname}}</i></el-button>
          </div>
        </el-popover>
      </template>
    </el-table-column>
    <el-table-column
        label="文件大小(B)"
        prop="dsize">
    </el-table-column>
    <el-table-column
        align="right">
      <template slot="header" slot-scope="scope">
        <el-input
            v-model="search"
            size="mini"
            placeholder="输入关键字搜索"/>
      </template>
      <template #default="scope">
        <el-button
            size="mini"
            type="danger"
            @click="handleDelete(scope.row.did)">Delete</el-button>
      </template>
    </el-table-column>
  </el-table>
</template>

<script>
export default {
  inject:　['reload','downloadFiles','dirdown','dirshow'],
  created() {
    var th =this
    axios({
      url:"http://82.156.197.128:8085/dir/findAllDir",
      method:"POST",
    }).then((resp)=>{
          th.tableData =resp.data;
    })
  },
  data() {
    return {
      tableData: [{
        ddate: '2016-05-02',
        dname: '王小虎',
        dsize: '上海市普陀区金沙江路 1518 弄'
      }],
      search: ''
    }
  },
  methods: {
    handleEdit() {

    },
    handleDelete(did) {
      console.log(did)
    var th=this;
      axios({
        url:"http://82.156.197.128:8085/dir/delDir",
        method:"POST",
        params:{
          "did":did
        }
      }).then((resp)=>{
      th.reload();
      })

    }
  },
}
</script>
